package lanqiao;

public class 递增序列 {
    public static void main(String[] args) {
       char[][] arr = {{'L','A','N','N'},{'Q','I','A','O'}};
        System.out.println(lan(arr,1,3,0));
    }
    public static int lan(char[][] arr,int i ,int j,int ans){
      if (j==0){
          return 0;
      }
      int n=0;
      if(arr[i][j]<=arr[i][j-1]){
         swap(arr[i][j],arr[i][j-1]);
         n= lan(arr,i,j-1,ans);
      }else {
          ans++;
      }
      return ans+n +lan(arr,i,j-1,ans);
    }
    public static void swap(char i,char j){
        char temp =i;
        i=j;
        j=temp;
    }
}
